package IO;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Microsoft
 * Date: 2023-07-26
 * Time: 21:14
 */
public class IODemo6 {
    public static void main(String[] args) throws IOException {
        //try with resources
        // 带有资源的try操作，会在try代码块结束，自动执行close关闭操作
        try(InputStream inputStream = new FileInputStream(".\\学.txt")){
            while (true) {
                int b = inputStream.read();//read无参一次读取一个字节，返回是int类型，当读到末尾，就会返回-1
                if (b == -1) {
                    break;
                }
                System.out.printf("%x\n",b);//16进制打印
            }
        }
    }
}














